﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using VietKinsNutrition.Data;
using VietKinsNutrition.Bussiness;

namespace VietKinsNutrition.UserControl
{
    public partial class FrmTblDanhsachhangtonkho : DevExpress.XtraEditors.XtraUserControl
    {
        DataRow dr;
        ClsTblDm_NhapthucphamBLL ClsTblDm_Nhapthucpham_bll = new ClsTblDm_NhapthucphamBLL();
        ClsTblDmTruonghocDAL ClsTblDmTruonghocdal = new ClsTblDmTruonghocDAL();
        ClsExport2ExcelBLL ClsExport2Excelbll = new ClsExport2ExcelBLL();
        string sTieude, sTenso, sTentruong, sTenphong;
        public FrmTblDanhsachhangtonkho()
        {
            InitializeComponent();
        }

        private void FrmTblDanhsachhangtonkho_Load(object sender, EventArgs e)
        {
            gridControl1.DataSource = ClsTblDm_Nhapthucpham_bll.TblDanhsachhangton();
            dateEdit1.Text = DateTime.Now.ToString("dd/MM/yyyy");
        }

        private void dateEdit1_EditValueChanged(object sender, EventArgs e)
        {
            gridControl1.DataSource = ClsTblDm_Nhapthucpham_bll.TblDanhsachhangtonByFindNameandNgayNX(textEdit1.Text.Trim(), dateEdit1.DateTime);
        }

        private void textEdit1_EditValueChanged(object sender, EventArgs e)
        {
            dateEdit1_EditValueChanged(sender, e);
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            gridControl1.DataSource = ClsTblDm_Nhapthucpham_bll.TblDanhsachhangtonByFindName("");
        }

        private void btnIn_Click(object sender, EventArgs e)
        {

            if (gridView1.RowCount <= 0)
                return;
            ClsTblTruonghocBLL ClsTblTruonghocbll = new ClsTblTruonghocBLL();
            DataTable Tbl = ClsTblTruonghocbll.ReturnTblTRuong();
            ClsExport2ExcelBLL ClsExport2Excelbll = new ClsExport2ExcelBLL();
            if (Tbl.Rows.Count > 0)
            {
                dr = Tbl.Rows[0];
                sTenso = dr["TensoGD"].ToString();
                sTentruong = dr["Tentruong"].ToString();
                sTenphong = dr["TenphongGD"].ToString();
                sTieude = "DANH SÁCH THỰC PHẨM TỒN";
            }
            DG_Danhsachhangton.DataSource = gridControl1.DataSource;
            //DataGridViewColumnCollection cl =  dataGridView.Columns;//["Thucpham_thucanId"].Visible = false;
            ClsExport2Excelbll.ExportFileExel(sTieude, sTenso, sTenphong, sTentruong, "Danhsachtonkho.xls", DG_Danhsachhangton, 1);
        }
    }
}
